const SequelizeAuto = require('sequelize-auto');
// const auto = new SequelizeAuto('ss', 'root', 'ba9vc2z16mZmmkc0cc');
const host = process.env.DB_HOST;
const port = process.env.DB_PORT;
const username = process.env.DB_USER;
const password = process.env.DB_PASSWORD;
const database = process.env.DB_NAME;
const auto = new SequelizeAuto(database, username, password, {
    host: host,
    dialect: 'mysql',//|'mariadb'|'sqlite'|'postgres'|'mssql',
    directory: `./db/models/${process.env.PROJECT_MODELS_DIR}`, // where to write files
    port: port,
    mangle: false,
    camelCase: false,
    pluralize: false,
    logging: JSON.parse(process.env.SHOW_SQL) === true ? (...msg) => console.log(msg) : false,                        // 禁用日志记录
    caseModel: 'c', // convert snake_case column names to camelCase field names: user_id -> userId
    // caseFile: 'c', // file names created for each model use camelCase.js not snake_case.js
    singularize: false, // convert plural table names to singular model names
    additional: {
        timestamps: false
        // ...options added to each model
    },
    // tables: ['table1', 'table2', 'myschema.table3'] // use all tables, if omitted
    //...
})
auto.run().then(data => {
    console.log(data.tables);      // table and field list
    console.log(data.foreignKeys); // table foreign key list
    console.log(data.indexes);     // table indexes
    console.log(data.hasTriggerTables); // tables that have triggers
    console.log(data.relations);   // relationships between models
    console.log(data.text)         // text of generated models
});
